package com.company.thread;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/10/21 17:15
 */
public class MyThread4 {
    public static void main(String[] args) {
        Ff ff = new Ff();

        Thread t1 = new Thread(ff, "T1");
        t1.start();

        try {
            Thread.sleep(200);
            System.out.println("t1状态："+t1.getState());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t1.interrupt(); //打断 t1
        System.out.println("退出main...");
    }




}

class Ff implements Runnable{
    @Override
    public void run() {
        try {
            System.out.println("进入sleep");
            Thread.sleep(20000);
            System.out.println("离开sleep");
        } catch (InterruptedException e) {
            System.out.println("进入InterruptedException");
            return;
        }
        System.out.println("退出线程");
    }
}

